package com.itheima.request.param;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.Map;
import java.util.Set;
@WebServlet("/demo4")
public class ServletDemo4 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       req.setCharacterEncoding("utf-8");
        String username = req.getParameter("username");
        String pwd = req.getParameter("pwd");
        String[] hobby = req.getParameterValues("hobby");
        System.out.println(username+"=="+pwd+"=="+"=="+Arrays.toString(hobby));
        System.out.println("----------------------");
        Map<String, String[]> map = req.getParameterMap();
        Set<String> keys = map.keySet();
        for (String key : keys) {
            String[] strings = map.get(key);
            System.out.println(key+"=="+Arrays.toString(strings));
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
